package com.dune.ajaxuo.client;

import com.dune.ajaxuo.shared.World;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.Timer;



/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class Ajax_UO implements EntryPoint {
	
	World world;
	
	//timer refresh rate, in milliseconds
	static final int refreshRate = 25;	

	/**
	 * This is the entry point method.
	 */
	public void onModuleLoad() {
		// init World
		world = new World();

	    // init handlers
	    world.initHandlers();
	    
	    // setup timer
	    final Timer timer = new Timer() {
	      @Override
	      public void run() {
	        doUpdate();
	      }
	    };
	    timer.scheduleRepeating(refreshRate);	
	}
	
	
	void doUpdate() {

		// update the world
	    world.update();
	    
		// draw the world
	    world.draw();
	}
	  
	

	  
}
